livecodefandomcom-20200223-history
Read from process
Accepts the output of a process that was opened with the open process command, placing the data in the it variable. Syntax: read from process at {until { | empty | end | EOF} | for []} in Examples: read from process "compileData" for 20 read from process "/etc/pr" at 2 until linefeed -- skip 2 chars read from process myProcess for 10 int4s in 250 milliseconds Use the read from process command to get the output data from another program. The processName is case-sensitive, even on platforms where file names are not case-sensitive. It must be exactly the same--including the case of characters--as the name you used with the open process command. The start specifies the character or byte position in the process output where you want to begin reading. The string is any expression that evaluates to a string. When LiveCode encounters the string in the process output, it stops reading. If the string is not encountered, the read from process command continues reading as long as there is data to be read. The amount is a positive integer and specifies how much data to read. The chunkType is one of chars, characters, words, items, lines, int1, uInt1, int2, uint2, int4, or uint4. The read from process command reads amount of the specified chunkType. If you don't specify a chunkType, amount characters are read. Please note that for computers: *INT1: 1-byte integer between 0 and 255. The length is set to 3 places for this data type. *INT2: 2-byte integer between -32767 and 32767. Fields of this type should only be used for length fields. These long fields are positioned immediately in front of a long field (type LCHR, LRAW). With INSERT or UPDATE on the long field, the database interface enters the length which was actually used in the length field. The length is set to 5 places for this data type. *INT4: 4-byte integer between -2147483647 bis 2147483647. The length is set to 10 places for this data type. The time is the time to wait for the read to be completed, in milliseconds, seconds, or ticks. The until string form reads data until the specified string is encountered. The until end and until eof forms read data until the process specifies it is finished. When until empty is used the data is read in at specified time intervals. If, when checked, the data is empty the openProcesses function is used to check whether the process has finished. Parameters: *processName: The processName specifies the name and location of the process you want to read from. It must be the same as the path you used with the open process command. Important: The processName is case-sensitive, even on platforms where file names are not case-sensitive. It must be exactly the same, including the case of characters, as the name you used with the open process command. *start: The start specifies the character or byte position in the process output where you want to begin reading. *chunkType:One of chars, characters, words, items, lines, int1, uInt1, int2, uint2,int4, or uint4. The read from process command reads amount of the specified chunkType. If you don't specify a chunkType, amount charactersare read. *time: The time to wait for the read to be completed, in milliseconds, seconds,or ticks. *string (string): When LiveCode encounters the string in the process output, it stopsreading. If the string is not encountered, the read from process command continues reading as long as there is data to be read. *amount: A positive integer and specifies how much data to read. *It: The data is placed in the it variable after reading. If you specified a binary data chunkType (int1, uInt1, int2, uint2, int4,or uint4), the data consists of a comma-separated list of numbers, onefor the numerical value of each chunk that was read. Otherwise, the datais placed in the it variable as it appears in the output. *The result: The process to read from must be opened first with the open process command, and the mode the process was opened in must be read or update. If the process is not running or is write-only, the result function is set to "Process is not open for read.". If the read from process command encounters the end of the data output, the result function is set to "eof". If you specify a time and the read is notcompleted when that time has elapsed, the result function is set to"time out". If the read was successful, the result is set to empty. See also: write to process (command),read from driver (command),open process command (command),EOF (constant),ticks (function),result (function),openProcesses (function),milliseconds (function)